export default {
  //时间格式化
  timeFormatting() {
    Date.prototype.Format = function (fmt) {
      var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        S: this.getMilliseconds() //毫秒
      };
      if (/(y+)/.test(fmt))
        fmt = fmt.replace(
          RegExp.$1,
          (this.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
      for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
          fmt = fmt.replace(
            RegExp.$1,
            RegExp.$1.length == 1 ?
            o[k] :
            ("00" + o[k]).substr(("" + o[k]).length)
          );
      return fmt;
    };
  },
  // 粒子特效
  particle() {
    if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {} else {
      $(function () {
        var canvas = document.querySelector("canvas"),
          ctx = canvas.getContext("2d");
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        ctx.lineWidth = 0.3;
        ctx.strokeStyle = new Color(150).style;
        var mousePosition = {
          x: (30 * canvas.width) / 100,
          y: (30 * canvas.height) / 100
        };
        var dots = {
          nb: 250,
          distance: 100,
          d_radius: 150,
          array: []
        };

        function colorValue(min) {
          return Math.floor(Math.random() * 255 + min);
        }

        function createColorStyle(r, g, b) {
          return "rgba(" + r + "," + g + "," + b + ", 0.8)";
        }

        function mixComponents(comp1, weight1, comp2, weight2) {
          return (comp1 * weight1 + comp2 * weight2) / (weight1 + weight2);
        }

        function averageColorStyles(dot1, dot2) {
          var color1 = dot1.color,
            color2 = dot2.color;
          var r = mixComponents(color1.r, dot1.radius, color2.r, dot2.radius),
            g = mixComponents(color1.g, dot1.radius, color2.g, dot2.radius),
            b = mixComponents(color1.b, dot1.radius, color2.b, dot2.radius);
          return createColorStyle(Math.floor(r), Math.floor(g), Math.floor(b));
        }

        function Color(min) {
          min = min || 0;
          this.r = colorValue(min);
          this.g = colorValue(min);
          this.b = colorValue(min);
          this.style = createColorStyle(this.r, this.g, this.b);
        }

        function Dot() {
          this.x = Math.random() * canvas.width;
          this.y = Math.random() * canvas.height;
          this.vx = -0.5 + Math.random();
          this.vy = -0.5 + Math.random();
          this.radius = Math.random() * 2;
          this.color = new Color();
        }
        Dot.prototype = {
          draw: function () {
            ctx.beginPath();
            ctx.fillStyle = this.color.style;
            ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false);
            ctx.fill();
          }
        };

        function createDots() {
          for (var i = 0; i < dots.nb; i++) {
            dots.array.push(new Dot());
          }
        }

        function moveDots() {
          for (var i = 0; i < dots.nb; i++) {
            var dot = dots.array[i];
            if (dot.y < 0 || dot.y > canvas.height) {
              dot.vx = dot.vx;
              dot.vy = -dot.vy;
            } else if (dot.x < 0 || dot.x > canvas.width) {
              dot.vx = -dot.vx;
              dot.vy = dot.vy;
            }
            dot.x += dot.vx;
            dot.y += dot.vy;
          }
        }

        function connectDots() {
          for (var i = 0; i < dots.nb; i++) {
            for (var j = 0; j < dots.nb; j++) {
              var i_dot = dots.array[i];
              var j_dot = dots.array[j];
              if (
                i_dot.x - j_dot.x < dots.distance &&
                i_dot.y - j_dot.y < dots.distance &&
                i_dot.x - j_dot.x > -dots.distance &&
                i_dot.y - j_dot.y > -dots.distance
              ) {
                if (
                  i_dot.x - mousePosition.x < dots.d_radius &&
                  i_dot.y - mousePosition.y < dots.d_radius &&
                  i_dot.x - mousePosition.x > -dots.d_radius &&
                  i_dot.y - mousePosition.y > -dots.d_radius
                ) {
                  ctx.beginPath();
                  ctx.strokeStyle = averageColorStyles(i_dot, j_dot);
                  ctx.moveTo(i_dot.x, i_dot.y);
                  ctx.lineTo(j_dot.x, j_dot.y);
                  ctx.stroke();
                  ctx.closePath();
                }
              }
            }
          }
        }

        function drawDots() {
          for (var i = 0; i < dots.nb; i++) {
            var dot = dots.array[i];
            dot.draw();
          }
        }

        function animateDots() {
          ctx.clearRect(0, 0, canvas.width, canvas.height);
          moveDots();
          connectDots();
          drawDots();
          requestAnimationFrame(animateDots);
        }
        $("canvas").on("mousemove", function (e) {
          mousePosition.x = e.pageX;
          mousePosition.y = e.pageY;
        });
        $("canvas").on("mouseleave", function (e) {
          mousePosition.x = canvas.width / 2;
          mousePosition.y = canvas.height / 2;
        });
        createDots();
        requestAnimationFrame(animateDots);
      });
    }
  },
  cetegories: [{
      label: "快递业与邮政",
      value: "快递业与邮政",
      children: [{
          label: "快递.物流",
          value: "快递.物流"
        },
        {
          label: "寄件/收件",
          value: "寄件/收件",
          qualify: "经营快递业务的企业需提交《快递业务经营许可证》/快递企业末端网点需提供所在地邮政管理部门备案证明"
        },
        {
          label: "邮政",
          value: "邮政",
          qualify: "《经营邮政通信业务许可证》"
        },
        {
          label: "装卸搬运",
          value: "装卸搬运"
        },
        {
          label: "仓储",
          value: "仓储"
        }
      ]
    },
    {
      label: "教育",
      value: "教育",
      children: [{
          label: "培训机构",
          value: "培训机构",
          qualify: "需提供区.县级教育部门颁发的《民办学校办学许可证》及营业执照（或事业单位法人证书.民办非企业单位登记证书）（18年新法规要求，仅针对新增帐号）"
        },
        {
          label: "驾校培训",
          value: "驾校培训",
          qualify: "《道路运输经营许可证》，且其中须有“驾驶员培训”项目"
        }
      ]
    },
    {
      label: "医疗",
      value: "医疗",
      children: [{
          label: "就医服务",
          value: "就医服务",
          qualify: "卫生和计划生育委员会/医管局批文或签订协议的医院列表.其中的一份协议.其中的一份承诺书.协议医院的《医疗机构执业许可证》"
        },
        {
          label: "医疗器械销售",
          value: "医疗器械销售",
          qualify: "《医疗器械生产经营许可证》.市食品药品监督管理部门备案凭证"
        }
      ]
    },
    {
      label: "出行与交通",
      value: "出行与交通",
      children: [{
        label: "停车",
        value: "停车"
      }]
    },
    {
      label: "房地产",
      value: "房地产",
      children: [{
          label: "物业管理",
          value: "物业管理"
        },
        {
          label: "房地产",
          value: "房地产"
        },
        {
          label: "装修/建材",
          value: "装修/建材"
        }
      ]
    },
    {
      label: "生活服务",
      value: "生活服务",
      children: [{
          label: "家政",
          value: "家政"
        },
        {
          label: "丽人",
          value: "丽人"
        },
        {
          label: "宠物(非医院类)",
          value: "宠物(非医院类)"
        },
        {
          label: "宠物医院/兽医",
          value: "宠物医院/兽医",
          qualify: "《动物诊疗许可证》"
        },
        {
          label: "摄影/扩印",
          value: "摄影/扩印"
        },
        {
          label: "婚庆服务",
          value: "婚庆服务"
        },
        {
          label: "搬家公司",
          value: "搬家公司"
        },
        {
          label: "百货/超市/便利店",
          value: "百货/超市/便利店"
        }
      ]
    },
    {
      label: "餐饮",
      value: "餐饮",
      children: [{
          label: "餐饮服务场所",
          value: "餐饮服务场所",
          qualify: "1.《食品经营许可证》或有效期内餐饮服务场所公共场所的《卫生许可证》2. 小程序主体为小作坊或食品摊贩的，需要出具当地所在地食品药品监督管理部门颁发的食品小作坊登记证或食品摊贩登记卡"
        },
        {
          label: "餐厅排队",
          value: "餐厅排队"
        },
        {
          label: "点餐平台",
          value: "点餐平台",
          qualify: "《增值电信业务经营许可证》"
        },
        {
          label: "外卖平台",
          value: "外卖平台",
          qualify: "《增值电信业务经营许可证》"
        }
      ]
    },
    {
      label: "旅游",
      value: "旅游",
      children: [{
          label: "酒店服务",
          value: "酒店服务"
        },
        {
          label: "公寓/民宿",
          value: "公寓/民宿"
        },
        {
          label: "门票",
          value: "门票"
        },
        {
          label: "景区服务",
          value: "景区服务"
        }
      ]
    },
    {
      label: "商家自营",
      value: "商家自营",
      children: [{
          label: "百货",
          value: "百货",
          qualify: "《食品经营许可证》"
        },
        {
          label: "食品",
          value: "食品",
          qualify: "1.鲜切蔬果类：提交《食品经营许可证》2.加工.预包装食品.饮料产品：提交《食品经营许可证》3.生食类产品：提交《食品经营许可证》"
        },
        {
          label: "初级食用农产品",
          value: "初级食用农产品",
          qualify: "1.未加工蔬果类：提交《企业营业执照》2.其他类初级食用农产品：提交《企业营业执照》"
        },
        {
          label: "酒/盐",
          value: "酒/盐",
          qualify: "《食品经营许可证》（含“预包装食品销售”)"
        },
        {
          label: "保健品",
          value: "保健品",
          qualify: "《国产保健食品批准证书》或《进口保健食品批准证书》或《食品经营许可证》（经营项目必须包含保健食品销售）或有效期内的生产资质"
        },
        {
          label: "成人用品",
          value: "成人用品",
          qualify: "第二类医疗器械经营备案凭证"
        },
        {
          label: "汽车/其他交通工具的配件",
          value: "汽车/其他交通工具的配件"
        },
        {
          label: "图书报刊/音像/影视/游戏/动漫",
          value: "图书报刊/音像/影视/游戏/动漫",
          qualify: "1. 批发：省级出版行政主管部门合法的《出版物经营许可证》 2. 零售：县（区）级出版行政主观部门合法的《出版物经营许可证》"
        },
        {
          label: "成品油",
          value: "成品油",
          qualify: "《成品油批发经营批准证书》或《成品油仓储经营批准证书》或《成品油零售经营批准证书》"
        },
        {
          label: "纪念币发售",
          value: "纪念币发售",
          qualify: "中国金币总公司的“特许零售商”资质文件"
        },
        {
          label: "电话卡销售",
          value: "电话卡销售",
          qualify: "两个及以上的市级及以上运营商合作协议，并加盖公司公章或合同专用章；和省级及以上运营商授权认证的《网络销售与实名制授权书》和运营商统一配发的授权防伪二维码标识（中国移动除外）"
        },
        {
          label: "服装/鞋/箱包",
          value: "服装/鞋/箱包"
        },
        {
          label: "海淘",
          value: "海淘"
        },
        {
          label: "玩具/母婴用品(不含食品)",
          value: "玩具/母婴用品(不含食品)"
        },
        {
          label: "家电/数码/手机",
          value: "家电/数码/手机"
        },
        {
          label: "美妆/洗护",
          value: "美妆/洗护"
        },
        {
          label: "珠宝/饰品/眼镜/钟表",
          value: "珠宝/饰品/眼镜/钟表"
        },
        {
          label: "运动/户外/乐器",
          value: "运动/户外/乐器"
        },
        {
          label: "鲜花/园艺/工艺品",
          value: "鲜花/园艺/工艺品"
        },
        {
          label: "家居/家饰/家纺",
          value: "家居/家饰/家纺"
        },
        {
          label: "汽车内饰/外饰",
          value: "汽车内饰/外饰"
        },
        {
          label: "办公/文具",
          value: "办公/文具"
        },
        {
          label: "宠物/农资",
          value: "宠物/农资"
        },
        {
          label: "五金/建材/化工/矿产品",
          value: "五金/建材/化工/矿产品"
        },
        {
          label: "机械/电子器件",
          value: "机械/电子器件"
        }
      ]
    },
    {
      label: "商业服务",
      value: "商业服务",
      children: [{
          label: "广告/设计",
          value: "广告/设计"
        },
        {
          label: "公关/推广/市场调查",
          value: "公关/推广/市场调查"
        },
        {
          label: "法律服务",
          value: "法律服务"
        },
        {
          label: "律所",
          value: "律所",
          qualify: "《律师事务所执业许可证书》 或 经司法厅批准成立法律服务机构的文件"
        },
        {
          label: "公证",
          value: "公证",
          qualify: "《公证处执业许可证》或与公证处的合作协议"
        },
        {
          label: "招聘/求职（中介类）",
          value: "招聘/求职（中介类）",
          qualify: "《人力资源服务许可证》"
        },
        {
          label: "会展服务",
          value: "会展服务"
        },
        {
          label: "拍卖公司（非文物）",
          value: "拍卖公司（非文物）",
          qualify: "《非经营性互联网信息服务备案核准》和《拍卖经营批准证书》和营业执照"
        },
        {
          label: "文物拍卖公司",
          value: "文物拍卖公司",
          qualify: "《非经营性互联网信息服务备案核准》和《拍卖经营批准证书》和《文物拍卖许可证》和营业执照"
        },
        {
          label: "典当",
          value: "典当",
          qualify: "《典当经营许可证》+ 《特种行业许可证》+《非经营性互联网信息服务备案核准》"
        },
        {
          label: "会计师事务所",
          value: "会计师事务所",
          qualify: "《会计师事务所执业证书》"
        },
        {
          label: "税务师事务所",
          value: "税务师事务所",
          qualify: "《税务师事务所执业证书》"
        },
        {
          label: "一般财务服务",
          value: "一般财务服务"
        },
        {
          label: "农林牧渔",
          value: "农林牧渔",
          qualify: "1. 初级农产品提交《全国工业产品生产许可证》2. 其他农产品提交《食品经营许可证》"
        }
      ]
    },
    {
      label: "公益",
      value: "公益",
      children: [{
          label: "公益慈善",
          value: "公益慈善",
          qualify: "民政部《基金会法人登记证书》或《慈善组织公开募捐资质证书》"
        },
        {
          label: "基金会",
          value: "基金会",
          qualify: "民政部《基金会法人登记证书》"
        }
      ]
    },
    {
      label: "体育",
      value: "体育",
      children: [{
        label: "体育场馆服务",
        value: "体育场馆服务"
      }]
    },
    {
      label: "汽车",
      value: "汽车",
      children: [{
          label: "养车/修车",
          value: "养车/修车"
        },
        {
          label: "汽车经销商/4S店",
          value: "汽车经销商/4S店"
        }
      ]
    }
  ]
}
